<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Register New User</title>
<script language="JavaScript" type="text/javascript">
function doValidation() {
	var uname=document.getElementById("user_name").value;
	var uid=document.getElementById("user_id").value;
	var passid=document.getElementById("password").value;
	var uemail=document.getElementById("email_id").value;
	var uphone_no=document.getElementById("phone_no").value;
	if (uname=="" || uid=="" || passid=="" || uphone_no=="" || uemail==""){
		alert("All fields are manadtaory.Please enter appropriately");
		return false;
	}
	var uid_len = document.getElementById("user_id").value.length;
	var pass_len = document.getElementById("password").value.length;
	if (uid_len < 5 || uid_len > 12)  
	{  
	alert("User Id should not be empty / length be between "+5+" to "+12);  
	return false;  
	}  
	if (pass_len < 5 || pass_len > 12)  
	{  
	alert("Password length should not be empty / length be between "+5+" to "+12);  
	return false;  
	}  
	if(uemail.indexOf('@gmail.com') === -1){
        alert("Please give your gmail ID only");
        return false;
	}
	 var lstrRefString="1234567890";
	 //var lstrInString = fnStripSpaces(distance);
	 var Count;
	 for (Count=0; Count < uphone_no.length; Count++)
	 {
		// alert("In for loop");
	       if (lstrRefString.indexOf (uphone_no.substring (Count, Count+1))==-1)
	 {
	   alert("Phone Number should be Integer");
	   return false;
	 }
	    }
	return true;  
	
}
</script>
</head>
<body>
<center><h2>Register New User</h2></center>
<s:form action="register_user">
<table id="msgcolor" border="0" align="center">
<tr>
<s:if test="%{msg==''}">
<td><h3></h3></td></s:if>
<s:else>
<td></td><td><h3><s:property value="msg"/> </h3></td>
</s:else>
</tr>
</table>
<table id="text" border="0" align="center">
<tr><s:textfield name="user_name" label = "User Name" id="user_name" size="20"/></tr>
<tr><s:textfield name="user_id" label = "User ID" id="user_id" size="20" /></tr>
<tr><s:password name="password" label = "Password" id="password" size="20" /></tr>
<tr><s:textfield name="email_id" label = "E-mail ID" id="email_id" size="20" /></tr>
<tr><s:textfield name="phone_no" label = "Phone Number" id="phone_no" size="20" /></tr>
<tr></tr><tr><s:submit name = "commandButton" id="mysubmit" value="Register" align="center" onClick="return doValidation()" /></tr>
</table>
</s:form>
</body>
</html>